# coding: utf-8

import easyquotation

from .base_engine import BaseEngine
from emmongo import em_mongomanager as mongoManager


class DefaultQuotationEngine(BaseEngine):
    """新浪行情推送引擎"""
    EventType = 'quotation'

    def init(self):
        self.source = easyquotation.use('sina')

    def fetch_quotation(self):
        stks = mongoManager.db[mongoManager.COL_SELF_FUND].find()
        if stks.count():
            l = list(stks)
            source = []
            for i in l:
                source.append(i['stk_code'])
            return self.source.stocks(source)
        return self.source.all
